#!/bin/bash

process_id=$(pgrep -f com.gray.boxstream)

if [ -n "$process_id" ]; then
  kill -9 "$process_id"
  echo "进程 com.gray.boxstream ($process_id) 已终止"
else
  echo "未找到进程 com.gray.boxstream"
fi

i=1
while [ $i -le 3 ]; do
  i=$((i+1))
  sleep 1
done

echo "占用端口 10002 ..."
/data/adb/magisk/busybox nc -l -p 10002 >/dev/null &
pid_10002=$!

echo "占用端口 10003 ..."
/data/adb/magisk/busybox nc -l -p 10003 >/dev/null &
pid_10003=$!

echo "占用端口 10004 ..."
/data/adb/magisk/busybox nc -l -p 10004 >/dev/null &
pid_10004=$!

echo "端口占用完成"

sleep 5

echo "释放占用端口..."
kill -9 $pid_10002 $pid_10003 $pid_10004

echo "脚本完成"
